package zh.javadesign.抽象工厂.scene.matter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
 * Copyright (C) 广州中和互联网技术有限公司
 *
 * @author 范家微 fanjiawei@borche.cn
 * @date :2021/2/2 21:36
 */
public class EGM {
	private Logger logger = LoggerFactory.getLogger(EGM.class);

	private Map<String, String> dataMap = new ConcurrentHashMap<String, String>();

	public String gain(String key) {
		logger.info("EGM获取数据 key：{}", key);
		return dataMap.get(key);
	}

	public void set(String key, String value) {
		logger.info("EGM写入数据 key：{} val：{}", key, value);
		dataMap.put(key, value);
	}

	public void setEx(String key, String value, long timeout, TimeUnit timeUnit) {
		logger.info("EGM写入数据 key：{} val：{} timeout：{} timeUnit：{}", key, value, timeout, timeUnit.toString());
		dataMap.put(key, value);
	}

	public void delete(String key) {
		logger.info("EGM删除数据 key：{}", key);
		dataMap.remove(key);
	}
}
